/**
 * @ClassName HttpProtocolUtil
 * @Deseription
 * @Author fx
 * @Date 2021/1/10 0010 15:49
 * @Version 1.0
 **/
public class HttpProtocolUtil {

    /**
     * @Author fx
     * @Description 响应 200 状态请求头信息
     * @ClassName HttpProtocolUtil
     * @Date 15:55 2021/1/10 0010
     * @Param
     * @return
     **/
    public static String getHead200(long contentLength){
        return "HTTP/1.1 200 OK \n" +
                "Content-Type: text/html \n" +
                "Content-Length: " + contentLength + " \n" +
                "\r\n";
    }

    /**
     * @Author fx
     * @Description 响应404请求头信息包含返回数据内容
     * @ClassName HttpProtocolUtil
     * @Date 15:54 2021/1/10 0010
     * @Param
     * @return
     **/
    public static String getHead404(){
        String str404 = "<h2>404 not found</h2>";
        return "HTTP/1.1 404 NOT FOUND \n" +
                "Content-Type: text/html \n" +
                "Content-Length: "+str404.getBytes().length + "\n" +
                "\r\n" + str404;
    }
}
